package com.example.blogsystem.mapper;

import com.example.blogsystem.model.Blog;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface BlogMapper {
    // 列表页：查询博客列表
    @Select("select * from blog where delete_flag != 1 order by create_time desc")
    List<Blog> blogAllBlog();

    // 详情页：根据博客id查询博客详情
    @Select("select * from blog where id = #{id}")
    Blog selBlogById(Integer id);

    // 根据博客id修改博客信息
    Integer  updateById(Blog blog);

    //添加博客
    @Insert("insert into blog (title, content, user_id) values" +
            " (#{title}, #{content}, #{userId})")
    Integer publishBlog(Blog blog);
}
